﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>1.0.登陆</title>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushCSharp.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushXml.js"></script>
    <link type="text/css" rel="stylesheet" href="../../Content/highlighter/styles/shCore.css"/>
    <link type="text/css" rel="stylesheet" href="../../Content/highlighter/styles/shCoreEclipse.css" />
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
    <h3>视图的调用方式</h3>
    <b>1.使用Render调用：</b>
    <pre class="brush: csharp;">
    public class IndexController:BaseController
    {
        public void Index()
        {
            //使用默认路径渲染
            this.Render();
        }
    }
    </pre>
    <b>
	 2.使用Render泛型调用：
    </b>
    <pre class="brush: csharp">
        public class RenderHelper
        {
            public static RenderHtml()
            {
                //定义视图类
                var Model=new NFinalCorePlug.Controllers.IndexController_Model.Index();
                Model.a=1;
                Model.b="Hello!";
                this.Render("NFinalPlug/Views/Index/Index.cshtml",Model);
            }
        }
    </pre>
    <b>3.使用RazorView调用视图</b>
    <pre class="brush: csharp">
        using System;
        using System.IO;
        using System.Net;
        using System.Collections.Generic;
        using NFinal;

        //此代码由NFinalRazorGenerator生成。
        //http://bbs.nfinal.com
        namespace NFinalCorePlug.Views.Index
        {
            //此属性参数为视图路径
            [View("/NFinalCorePlug/Views/Index/Default.cshtml")]
            public class Default : NFinal.View.RazorView&lt;NFinalCorePlug.Controllers.IndexController_Model.Index>
            {
                public Default(NFinal.IO.Writer writer, NFinalCorePlug.Controllers.IndexController_Model.Index Model) : base(writer, Model)
                {
                }
                //如果此处报错，请添加NFinal引用
                //PMC命令为：Install-Package NFinal
                public override void Execute()
                {
                    writer.Write("");
                    writer.Write("&lt;!DOCTYPE html>\r\n&lt;html>\r\n\r\n&lt;head>&lt;/head>\r\n&lt;body>");
                    writer.Write(Model.a);
                    writer.Write("&lt;/body>\r\n&lt;/html>");
                }
            }
        }
        //其中StringWriter,StreamWriter,FileWriter均继承自NFinal.IO.Writer
        public void WriteToFile()
        {
            FileWriter writer=new FileWriter("c:\Index.html");
            var Model=new NFinalCorePlug.Controllers.IndexController_Model.Index();
            Model.a=1;
            Model.b="Hello!";
            var template=new NFinalCorePlug.Views.Index(writer,Model);
            template.Execute();
        }
    </pre>
    <b></b>
</body>
</html>